package com.du;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author : DuJiabao
 * @Date : 2021/1/30 10:18
 * @Project : java-web
 * @File : null.java
 * @Desc : 以Servlet的方式生成HTML
 */
public class Demo1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");  // 设置返回数据类容及编码格式
        PrintWriter writer = resp.getWriter();  // 返回字符输出流
        // 写一个HTML文件出来
        writer.write("<!DOCTYPE html>");
        writer.write("<html>");
        writer.write("<head>");
        writer.write("<title>JSP - Hello World</title>");
        writer.write("</head>");
        writer.write("<body>");
        writer.write("<h1>");
        writer.write("你好世界");
        writer.write("</h1>");
        writer.write("<body>");

    }
}
